package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F104 附加信息
 *
 * @author yangfan
 * @version 1.0
 * @date 2021/5/6
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F104_FORMATTER {
    SI("SI", "发送方辅助验证信息"),
    AI("AI", "航空行业应用数据"),
    CD("CD", "持卡人IP和设备信息"),
    MU("MU", "资金用途"),
    CC("CC", "单位结算卡数据"),
    BI("BI", "业务及产品标识"),
    PI("PI", "终端信息"),
    EM("EM", "增强型商户信息"),
    AG("AG", "账户类别"),
    SC("SC", "特殊清算信息"),
    RT("RT", "关联交易的主键信息"),
    IV("IV", "实名认证标识"),
    TR("TR", "转账结果信息"),
    TT("TT", "转账时效信息"),
    TI("TI", "转入方身份标识信息"),
    TO("TO", "转出方身份标识信息"),
    CP("CP", "保留使用"),
    BB("BB", "保留使用"),
    ;

    private String code;
    private String desc;

    F104_FORMATTER(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F104_FORMATTER find(String code) {
        F104_FORMATTER result = Arrays.stream(F104_FORMATTER.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
